#!/bin/bash
#
#$ -cwd
#$ -j y
#$ -S /bin/bash
#
###############################################
###### IRIS-Processor #########################
###############################################

# This script processes an iris-database the following way
# Input Image 	=> Segmentation result (<filename>.png)
#		=> Iris code	       (<filename>.png)


TOOL=$1
TARGET=$2

SRC=$TARGET/itex
TARGET_IC=$TARGET/ic
TOOLDIR=bin

IC_EXT=png

if [ $# -ne 2 ] ; then

echo 'Call with two parameters:'
echo 'first: tool as in bin-directory'
echo 'second: directory, where an itex folder resides (besides an ic/<tool> folder is going to be generated)'

exit
fi

echo 'Run ' $TOOL ' on segmentation ' $SRC



 # Clean up
rm -rf $TARGET_IC/$SEGMENT/$TOOL


# Segmentations that are available
      

    mkdir -p $TARGET_IC/$SEGMENT/$TOOL

    FILELIST=`ls $SRC`

     # echo $FILELIST


    for INPUTFILE in $FILELIST
    do

      # Retrieve the Filename without the suffix... FIXME: Hardcoded suffixes!!

      extension="${INPUTFILE##*.}"
      y=${INPUTFILE%.$extension}
      FNAME=`echo ${y##*/}`

      echo $TOOL ': Processing ' $FNAME
      INPUT=$SRC/$INPUTFILE

      $TOOLDIR/$TOOL -i $SRC/$INPUTFILE -o $TARGET_IC//$TOOL/$FNAME.$IC_EXT -q
      
    done
